package cn.edu.scau.nursingcenter.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.scau.nursingcenter.dao.Stay_backRepository;
import cn.edu.scau.nursingcenter.entiry.Stay_back;
import cn.edu.scau.nursingcenter.service.Stay_backService;

/**
 * 业务逻辑层接口实现类Stay_backServiceImpl
 * @author feng
 *
 */
@Service
public class Stay_backServiceImpl implements Stay_backService{
	@Autowired
	private Stay_backRepository stay_backRepository;

	/**
	 * 显示所有退住信息
	 * @return
	 */
	@Override
	public List<Stay_back> selectAll() {
		return stay_backRepository.findAll();
	}

	/**
	 * 根据客户名字查询
	 * @param name
	 * @return
	 */
	@Override
	public List<Stay_back> findByName(String name) {
		return stay_backRepository.findByName(name);
	}

	/**
	 * 新增退住
	 * @param stay_back
	 * @return
	 */
	@Override
	public Stay_back insert(Stay_back stay_back) {
		return stay_backRepository.save(stay_back);
	}

	/**
	 * 根据编号删除
	 * @param id
	 */
	@Override
	public void delete(Integer id) {
		stay_backRepository.deleteById(id);
	}

	/**
	 * 根据客户编号查询
	 * @param id
	 * @return
	 */
	@Override
	public Stay_back findById(Integer id) {
		return stay_backRepository.findById(id).isPresent()?stay_backRepository.findById(id).get():null;
	}

	

}
